<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            菜鸟教程
        </title>
    </head>

    <script>
        var txt = ""
        function message()
        {
            try {
                adddlert("Welcome guest!")
            } catch (error) {
                txt = "本页有一个错误。\n\n"
                txt += "错误描述：" + error.message + "\n\n"
                txt += "点击确定继续。\n\n"
                alert(txt)
            }
        }
    </script>

    <body>
        <!-- <h1>JavaScript 字符串</h1>
        <h2>中括号</h2>
        <p>中括号 [] 返回字符串中对应索引位置的字符：</p>
        <p id = "demo"></p> -->
        <input type="button" value="查看消息" onclick="message()" />
        
    </body>
</html>